import React from 'react';
import PropTypes from 'prop-types';
import _ from 'lodash';

import Item from './item';

class Items extends React.Component {
    static propTypes = {
        items: PropTypes.array,
        updateItem: PropTypes.func,
    };

    render() {
        console.dir('items render');
        let items = [];
        _.forEach(this.props.items, (item, index) => {
            items.push(
                <Item key={index}
                      item={item}
                      update={this.props.updateItem(index)}
                />
            );
        });
        return (
            <ul>
                {items}
            </ul>
        )
    }
}

export default Items;
